#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>

using namespace std;

int main() {
    int a, b;
    while (cin >> a) {
        cin >> b;
        int resA = 0, resB = 0;
        for (int i = 2; i < a / i; ++i) {
            if (a % i == 0) resA += i + a / i;
        }
        for (int i = 2; i < b / i; ++i) {
            if (b % i == 0) resB += i + b / i;
        }
        if (resB + 1 == a && resA + 1 == b) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}